package com.hjm.project.CkPosReturn.CkPosReturn.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.CkPosReturn.CkPosReturn.domain.CkPosReturn;
import com.hjm.project.CkPosReturn.CkPosReturn.service.ICkPosReturnService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 终端达标返现奖励Controller
 * 
 * @author LOVE
 * @date 2020-11-27
 */
@Controller
@RequestMapping("/CkPosReturn/CkPosReturn")
public class CkPosReturnController extends BaseController
{
    private String prefix = "CkPosReturn/CkPosReturn";

    @Autowired
    private ICkPosReturnService ckPosReturnService;

    @RequiresPermissions("CkPosReturn:CkPosReturn:view")
    @GetMapping()
    public String CkPosReturn()
    {
        return prefix + "/CkPosReturn";
    }

    @GetMapping("/one")
    public String CkPosReturnOne() {
        return prefix + "/CkPosReturnOne";
    }

    /**
     * 查询终端达标返现奖励列表
     */
    @RequiresPermissions("CkPosReturn:CkPosReturn:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CkPosReturn ckPosReturn)
    {
        startPage();
        List<CkPosReturn> list = ckPosReturnService.selectCkPosReturnList(ckPosReturn);
        return getDataTable(list);
    }

    /**
     * 导出终端达标返现奖励列表
     */
    @RequiresPermissions("CkPosReturn:CkPosReturn:export")
    @Log(title = "终端达标返现奖励", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CkPosReturn ckPosReturn)
    {
        List<CkPosReturn> list = ckPosReturnService.selectCkPosReturnList(ckPosReturn);
        ExcelUtil<CkPosReturn> util = new ExcelUtil<CkPosReturn>(CkPosReturn.class);
        return util.exportExcel(list, "CkPosReturn");
    }

    /**
     * 新增终端达标返现奖励
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存终端达标返现奖励
     */
    @RequiresPermissions("CkPosReturn:CkPosReturn:add")
    @Log(title = "终端达标返现奖励", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CkPosReturn ckPosReturn)
    {
        return toAjax(ckPosReturnService.insertCkPosReturn(ckPosReturn));
    }

    /**
     * 修改终端达标返现奖励
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        CkPosReturn ckPosReturn = ckPosReturnService.selectCkPosReturnById(id);
        mmap.put("ckPosReturn", ckPosReturn);
        return prefix + "/edit";
    }

    /**
     * 修改保存终端达标返现奖励
     */
    @RequiresPermissions("CkPosReturn:CkPosReturn:edit")
    @Log(title = "终端达标返现奖励", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CkPosReturn ckPosReturn)
    {
        return toAjax(ckPosReturnService.updateCkPosReturn(ckPosReturn));
    }

    /**
     * 删除终端达标返现奖励
     */
    @RequiresPermissions("CkPosReturn:CkPosReturn:remove")
    @Log(title = "终端达标返现奖励", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(ckPosReturnService.deleteCkPosReturnByIds(ids));
    }
}
